package app.android.alampang.model;

import android.os.Parcel;
import android.os.Parcelable;

import org.json.JSONObject;

/**
 * Created by Supanut on 1/18/2015.
 */
public class Place extends BaseModel {
    private String name;
    private int imageDrawable;
    private String hilightColor;
    private String alternativeName;
    private String latitude;
    private String longitude;
    private String content;

    public Place()
    {
        PARSING_NAME = "PLACE";
    }

    public Place(String jsonString)
    {
        this();
        parseFromJSONString(jsonString);
    }

    public void setAlternativeName(String alternativeName) {
        this.alternativeName = alternativeName;
    }

    public void setLatitude(String lattitude) {
        this.latitude = lattitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getAlternativeName() {

        return alternativeName;
    }

    public String getLatitude() {
        return latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public String getContent() {
        return content;
    }

    public void setHilightColor(String hilightColor) {
        this.hilightColor = hilightColor;
    }

    public void setImageDrawable(int imageDrawable) {
        this.imageDrawable = imageDrawable;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public int getImageDrawable() {
        return imageDrawable;
    }

    public String getHilightColor() {
        return hilightColor;
    }

//    private Place(Parcel in) {
//        name = in.readString();
//        imageDrawable = in.readInt();
//        hilightColor = in.readString();
//        alternativeName = in.readString();
//        latitude = in.readString();
//        longitude = in.readString();
//        content = in.readString();
//    }

//    @Override
//    public int describeContents() {
//        return 0;
//    }
//
//    @Override
//    public void writeToParcel(Parcel out, int flags) {
//        out.writeString(name);
//        out.writeInt(imageDrawable);
//        out.writeString(hilightColor);
//        out.writeString(alternativeName);
//        out.writeString(latitude);
//        out.writeString(longitude);
//        out.writeString(content);
//    }

//    public static final Parcelable.Creator<Place> CREATOR = new Parcelable.Creator<Place>()
//    {
//        public Place createFromParcel(Parcel in) {
//            return new Place(in);
//        }
//
//        public Place[] newArray(int size) {
//            return new Place[size];
//        }
//    };


    @Override
    public JSONObject toJSONObject() {
        JSONObject json = new JSONObject();
        try {


            json.put("name", name);
            json.put("alternativeName", alternativeName);
            json.put("imageDrawable", imageDrawable);
            json.put("hilightColor", hilightColor);
            json.put("latitude", latitude);
            json.put("longitude", longitude);
            json.put("content", content);


        }
        catch (Exception e){}
        return json;
    }

    @Override
    public void parseFromJSONString(String jsonString) {
        try
        {
            JSONObject json = new JSONObject(jsonString);
            name = json.getString("name");
            alternativeName = json.getString("alternativeName");
            imageDrawable = json.getInt("imageDrawable");
            hilightColor = json.getString("hilightColor");
            latitude = json.getString("latitude");
            longitude = json.getString("longitude");
            content = json.getString("content");
        }
        catch (Exception e)
        {

        }
    }
}
